#!/bin/bash

# 检查conda命令是否可用
if ! command -v conda &> /dev/null; then
    # 检查Miniconda安装文件是否存在
    if [ ! -f "Miniconda3-latest-Linux-x86_64.sh" ]; then
        # 下载Miniconda
        echo "正在下载Miniconda..."
        wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
    fi

    # 安装Miniconda
    echo "正在安装Miniconda..."
    bash Miniconda3-latest-Linux-x86_64.sh -b

    # 更新PATH并初始化conda
    echo "正在更新PATH并初始化conda..."
    echo 'export PATH="$HOME/miniconda3/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
    conda init bash
else
    echo "Conda已经安装。跳过安装步骤。"
fi

# 创建并激活conda环境
echo "创建并激活conda环境..."
conda create --name wgz_env python=3.10 -y
source ~/.bashrc
source activate wgz_env

# 更新conda并安装必要的软件包
echo "更新conda并安装必要的软件包..."
conda update -n base -c defaults conda -y
pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple django flask opencv-python scikit-learn numpy faiss-cpu tensorflow Pillow

echo "安装完成。环境'wgz_env'已设置好。"
